/* Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1396
  Verdict: Accepted
*/
import java.math.*;
import java.util.*;
import java.io.*;
 
public class Main {
 
    public BufferedReader in;
    public StringTokenizer stoken = new StringTokenizer("");
    public PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        new Main();
    }  
 
    Main() throws IOException{
        in = new BufferedReader(new FileReader("input.txt")); 
        out = new PrintWriter(new FileWriter("output.txt"));
	    nextInt();
	    BigInteger n = new BigInteger(nextString());
	    BigInteger m = new BigInteger(nextString());
	    int tt = n.compareTo(m);
	    while (tt != 0) {
	    	if (tt == 1)
	    		n = n.shiftRight(1);
	    	else
	    		m = m.shiftRight(1);
	    	tt = n.compareTo(m);
	    }
        out.print(n.toString());
	    out.close();
	}
 
    private int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextString());
    }
 
    private String nextString() throws IOException {
        while(!stoken.hasMoreTokens()){
            String st = in.readLine();
            stoken = new StringTokenizer(st);
        }
        return stoken.nextToken();
    }
 
} 